package com.huang.community.Entity;

import com.alibaba.fastjson.JSONObject;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.nio.charset.StandardCharsets;
/**
 * 队列消息发送者
 * @author TianTian
 * @date 2022/4/28 22:14
 */
@Component
public class EventProduce {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    public void send(Event event){
        rabbitTemplate.convertAndSend("X",event.getTopic(), JSONObject.toJSONString(event));
    }
}
